SET SERVEROUTPUT ON SIZE 1000000;
set verify off;

DECLARE
	l_total_extracted	NUMBER;
	l_total_imported	NUMBER;		
	l_func_id			VARCHAR2(100):='CAPAPREC_AP_BANK_AC_USE';	
BEGIN	

	
	SELECT COUNT(1) 
	INTO l_total_extracted
	FROM
		GL_SETS_OF_BOOKS			B,
		AP_BANK_ACCOUNTS_ALL		A,
		AP_BANK_ACCOUNT_USES_ALL	S
	WHERE	B.Short_Name		=	UPPER('&1')
	AND		B.Set_Of_Books_ID	=	A.Set_Of_Books_ID
	AND		A.Account_Type		=	'SUPPLIER'
	AND		A.Bank_Account_ID	=	S.External_Bank_Account_ID;
		
	SELECT COUNT(1) 
	INTO l_total_imported
	FROM CRST_AP_BANK_ACCOUNT_USES;
	
	dbms_output.put_line('Function: '||l_func_id);		
	dbms_output.put_line('Total Extracted: '||TO_CHAR(l_total_extracted)) ;
	dbms_output.put_line('Total Imported:  '||TO_CHAR(l_total_imported));
	IF l_total_extracted <> l_total_imported THEN
		dbms_output.put_line('Error: No. of Records do not match!');
	END IF;		
						
EXCEPTION
	WHEN OTHERS THEN	
		dbms_output.put_line('Function Error: '||l_func_id);
END;
/